<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="/css/template.css" rel="stylesheet" type="text/css" />
<title>Show Phone Repair Status For Shop</title>
</head>
<?php
$insstr1 = '
<table width="230" border="0" cellspacing="10" cellpadding="0">
  <tr>
    <td style="width:16px; border-color:#333; background-color:#FFFF00; border-style:solid; border-width:1px;">A</td>
    <td>Waiting For HQ Pick Up</td>
  </tr>
</table>
';
$insstr2 = '
<table width="230" border="0" cellspacing="10" cellpadding="0">
  <tr>
    <td style="width:16px; border-color:#333; background-color:#00B0F0; border-style:solid; border-width:1px;">B</td>
    <td>In Transit (Shop to HQ)</td>
  </tr>
</table>
';
$insstr3 = '
<table width="230" border="0" cellspacing="10" cellpadding="0">
  <tr>
    <td style="width:16px; border-color:#333; background-color:#FFC000; border-style:solid; border-width:1px;">C</td>
    <td>Before Quote</td>
  </tr>
</table>
';
$insstr4 = '
<table width="230" border="0" cellspacing="10" cellpadding="0">
  <tr>
    <td style="width:16px; border-color:#333; background-color:#92D050; border-style:solid; border-width:1px;">D</td>
    <td>After Quote</td>  
  </tr>
</table>
';
$insstr5 = '
<table width="230" border="0" cellspacing="10" cellpadding="0">
  <tr>
    <td style="width:16px; border-color:#333; background-color:#E6B8B7; border-style:solid; border-width:1px;">E</td>
    <td>Phone Fixed / Phone Can\'t Fix</td>
  </tr>
</table>
';
$insstr6 = '
<table width="230" border="0" cellspacing="10" cellpadding="0">
  <tr>
    <td style="width:16px; border-color:#333; background-color:#00B0F0; border-style:solid; border-width:1px;">F</td>
    <td>In Transit (HQ to Shop)</td>
  </tr>
</table>
';
$insstr7 = '
<table width="230" border="0" cellspacing="10" cellpadding="0">
  <tr>
    <td style="width:16px; border-color:#333; background-color:#BFBFBF; border-style:solid; border-width:1px;">G</td>
    <td>In Store, Waiting Customer Pickup</td>
  </tr>
</table>
';
$insstr8 = '
<table width="230" border="0" cellspacing="10" cellpadding="0">
  <tr>
    <td style="width:16px; border-color:#333; background-color:#FFFFFF; border-style:solid; border-width:1px;">H</td>
    <td>Pick Up, Case Closed.</td>  
  </tr>
</table>
';

$rCenterMapping = $this->rCenterMapping;
$shopHead = $this->shophead;
$idShop = $rCenterMapping[$shopHead];

?>


<body>

<H1><?php echo $this->shophead;?> | <a href="/repaircenter/mainpage/shop/<?php echo $this->shophead;?> ">Back to Main Page</a></H1>
<form id="form1" name="form1" method="post" action="/repaircenter/showstatusbyjobid">
       <input type="text" name="id_job" id="id_job" style="width:250px;" />
       <input type="hidden" name="shop_head" id="shop_head" value="<?php echo $this->shophead;?>" />
       <input type="submit" name="go" id="go" value="GO TO THIS JOBID" />
</form>
Current Opening Jobs:<br />
<table width="1150" border="1" cellspacing="0" cellpadding="10">
<?php foreach($this->openJobs as $brand => $bList){?>
  <tr>
    <td><?php echo $brand;?></td>
    <?php foreach($bList as $model => $qty){?>
    <td><?php echo $model.": x ".$qty." ";?></td>
    <?php }?>
  </tr>
<?php }?>
</table>




Status List:
<table width="1000" border="0" cellspacing="10" cellpadding="0">
  <tr>
    <td style="width:16px; border-color:#333; background-color:#FFFF00; border-style:solid; border-width:1px;">A</td>
    <td>Waiting For HQ Pick Up</td>
    <td style="width:16px; border-color:#333; background-color:#00B0F0; border-style:solid; border-width:1px;">B</td>
    <td>In Transit (Shop to HQ)</td>
    <td style="width:16px; border-color:#333; background-color:#FFC000; border-style:solid; border-width:1px;">C</td>
    <td>Before Quote</td>
    <td style="width:16px; border-color:#333; background-color:#92D050; border-style:solid; border-width:1px;">D</td>
    <td>After Quote</td>        
  </tr>
  <tr>
    <td style="width:16px; border-color:#333; background-color:#E6B8B7; border-style:solid; border-width:1px;">E</td>
    <td>Phone Fixed / Phone Can't Fix</td>
    <td style="width:16px; border-color:#333; background-color:#00B0F0; border-style:solid; border-width:1px;">F</td>
    <td>In Transit (HQ to Shop)</td>
    <td style="width:16px; border-color:#333; background-color:#BFBFBF; border-style:solid; border-width:1px;">G</td>
    <td>In Store, Waiting Customer Pickup</td>
    <td style="width:16px; border-color:#333; background-color:#FFFFFF; border-style:solid; border-width:1px;">H</td>
    <td>Pick Up, Case Closed.</td>            
  </tr>
</table>

<hr>

<table width="1150"  cellspacing="0" cellpadding="1" style="border:#06C solid 1px;">
  <tr>
    <td style="width:150px;" class="thetbheader">Job ID</td>
    <td style="width:150px;" class="thetbheader">Shop</td>
    <td style="width:180px;" class="thetbheader">Mobile</td>
    <td style="width:180px;" class="thetbheader">Customer Contacts</td>
    <td colspan="2" align="center" class="thetbheader" style="width:240px;">Status</td>
    <td align="center" style="width:150px;" class="thetbheader">Repair By</td>
    <td style="width:80px;"class="thetbheader" >Last Update</td>
    <td colspan="7" align="center" valign="middle" class="thetbheader">Actions</td>
  </tr>
<?php 
$lastStatusList = new Model_DbTable_Repairstatusrecord();
if(empty($this->searchresult)){
?>
<tr>
	<td colspan="15"> No record at the moment</td>
</tr>
<?php	
	}
else{
$counter = 0;		
foreach($this->searchresult as $k=>$v){
$theLastStatus = $lastStatusList->getLastStatus($v['id_job']);
if($theLastStatus[0]['id_status'] == $v['id_status'] and $theLastStatus[0]['time_record'] == $v['time_record'] ){	
?>
  <tr
  <?php 
  if($counter%2 ==1 ){ 
  echo 'class="thelineback"';
  }
  $counter++;
  ?>
  >
    <td><?php echo $v['id_job'];?><a href="/repaircenter/viewdetailstatus/jobid/<?php echo $v['id_job'];?>" style="font-size:12px;" target="_blank" ><img src="/css/details.gif" /></a></td>
    <td><?php echo $v['shop_code']; ?></td>
    <td><?php echo $v['mobile_brand']." ".$v['mobile_model']; ?></td>
    <td><?php echo $v['customer_name'];?><a href="/repairjob/<?php echo $v['shop_code'] ?>/<?php echo $v['id_job'];?>.html" style="font-size:12px;" target="_blank"><img src="/im/icon_print.gif" /></a></td>
    <td style="width:230px;">	
	[<?php echo $v['id_status'];?>]
    <?php
    $newStatus = new Model_DbTable_Jobstatus();
	echo $newStatus->getStatusDes($v['id_status']);
	?>	
    <?php
	if($v['id_status'] == 1 or $v['id_status'] == 3 or $v['id_status'] == 5 or $v['id_status'] == 7  ){ echo $insstr1;}
	if($v['id_status'] == 8 or $v['id_status'] == 9 ){ echo $insstr2;}
	if($v['id_status'] == 12 or $v['id_status'] == 14 or $v['id_status'] == 16 ){ echo $insstr3;}
	if($v['id_status'] == 18 or $v['id_status'] == 20 or $v['id_status'] == 22 or $v['id_status'] == 24  ){ echo $insstr4;}
	if($v['id_status'] == 23 or $v['id_status'] == 25 or $v['id_status'] == 29 ){ echo $insstr5;}
	if($v['id_status'] == 26 or $v['id_status'] == 27 ){ echo $insstr6;}
	if($v['id_status'] == 28 or $v['id_status'] == 30 ){ echo $insstr7;}
	if($v['id_status'] == 80 or $v['id_status'] == 90 ){ echo $insstr8;}
	?>
 
    </td>
    <td style="width:10px;"><a href="/repaircenter/viewhistory/jobid/<?php echo $v['id_job'];?>" style="font-size:12px;" target="_blank"><img src="/css/details.gif" /></a> </td>
    <td align="center" style="width:10px;">
   <?php  if($v['repair_staff'] == 0 || $v['repair_staff'] == null ){ ?>
	<a href="/repaircenter/add-repair-staff/jobid/<?php echo $v['id_job'];?>" target="_blank" > Add Repair Staff </a>
   <?php }
   else{
	$sDetail = new Model_DbTable_Roster_Stafflogindetail();
	$stLine = $sDetail->getDetail($v['repair_staff']);
	echo ucwords($stLine["ni"]);
	  }
    ?>
    </td>
    <td align="center"><?php echo $v['time_record'];?></td>
    <td align="center" valign="middle"><a href="/repaircenter/changestatusshop/jobid/<?php echo $v['id_job'];?>" style="font-size:12px;" target="_blank"><img src="/css/edit.gif" />
Status</a></td>
    <td align="center" valign="middle"><a href="/repaircenter/changequote/jobid/<?php echo $v['id_job'];?>" style="font-size:12px;"  target="_blank" ><img src="/css/edit.gif" />
Quote</a></td>
    <td align="center" valign="middle"><a href="/repaircenter/updateinvoice/jobid/<?php echo $v['id_job'];?>" style="font-size:12px;"  target="_blank"><img src="/css/edit.gif" />
Invoice</a></td>
    <td align="center" valign="middle">
    <?php
    if($idShop!=99){
	?>
      <a target="_blank" href="/repairparts/parts-record-with-borrow/shophead/<?php echo $v['shop_code'];?>/shop/<?php echo $idShop;?>/jobid/<?php echo $v['id_job'];?>">
      Parts<br />
      Record</a>
      <?php }?>
      </td>
    <td align="center" valign="middle" style="padding:5px;">&nbsp;</td>
  </tr>
    <tr>
    <td style="height:40px;">
    Part(s) Record On:<br />
    <?php
    $rStock = new Model_DbTable_Pr_Prstockmovement();
	$tmprows = $rStock->getPartsRecordByJobId($v['id_job']);
	if(isset($tmprows) && count($tmprows) > 0){
		//var_dump($tmprows);
		echo $tmprows[0]['date_move'];
		}
	else{
		echo "NoRecord";
		}	
	?>
    </td>
    <td colspan="12" style="height:40px;">
      <?php
	$rProducts = new Model_DbTable_Pr_Prproducts();
	$rBorrow = new Model_DbTable_Pr_Loan();
	
 	if(isset($tmprows) && count($tmprows) > 0){
		//var_dump($tmprows);
		foreach($tmprows as $key => $value){
			
			$rowProduct = $rProducts->getProduct($value['id_product']);
			echo "[".$rowProduct['code_product']."] ".$rowProduct['title_product']." ";
			if($value['code_move'] == 2){
				echo "x ";
				}
			elseif($value['code_move'] == 7){
				echo "x -";
				}	
			
			echo $value['qty_product'];
			
			$bLine = $rBorrow->getByStMoveCode($value['id_move']);
			
			if($bLine){
				
				echo " Borw Code :[{$bLine['b_code']}] ";
				
				echo ($bLine['confirmed'])?"<span style=\"color:#0f0;\" title = \"Borrow Action Confirmed By Other Party,Stock Has Been Adjusted\">Confirmed</span>":"<span style=\"color:#f00;\" title = \"Borrow Action Hasn't Been Confirmed By Other Party,Stock Has Not Been Adjusted YET\" >Not Confirm Yet</span>";
				
				}
			echo "<br />";	
			}	
		}   
	?>    </td>
  </tr>
  <tr>
  <td style="height:40px;">
  Comment<br />
  [<?php echo $v['id_job'];?>]:
  </td>
  <td colspan="12" style="height:40px;">
    <?php
  		$commentRecords = new Model_DbTable_Jobcomments();
		$commentList = $commentRecords->listCommentByJobID($v['id_job']);	
  if(isset($commentList)){
	  foreach($commentList as $k1 =>$v1){
	?>	  
    Comment by [<?php echo $v1['staffname_repair_comt']?>] on <?php echo $v1['date_repair_comt']?>,<?php echo $v1['time_repair_comt']?> <br /><div style=" border:#666 1px solid;"><?php echo $v1['content_repair_comt']?></div>
    <?php	  
		  }	  
	  } 
  ?>  </td>  
  </tr>

<?php
}
}
}
?>
</table>
</body>
</html>
